package chapter04.d2_robust.demo1;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: jack_yang
 * @Date: 2024/5/8
 * @Description: addition and subtraction
 */
public class Operation {
    public String generateAddOperation(int leftNum,int rightNum) throws IllegalAccessException {
        if(leftNum<0 || rightNum>100){
            throw new IllegalAccessException("左运算数不在0-100的范围之间");
        }
        if(rightNum<0 || rightNum>100){
            throw new IllegalAccessException("右运算数不在0-100的范围之间");

        }
        int value = leftNum + rightNum;
        if(value>100){
            throw new IllegalAccessException("运算结果大于100");
        }
        return leftNum + "+" + rightNum + "=" + value;
    }
}
